package org.alwayssuper.protocol.commons;

/**
 * @author alwaysSuper
 */
public enum VersionType {
    V2016((int) 0, (int) 0x2323),
    V2025((int) 1, (int) 0x2424);
    
    private final int value;
    private final int headerIdentifier;
    
    VersionType(int value, int headerIdentifier) {
        this.value = value;
        this.headerIdentifier = headerIdentifier;
    }
    
    public int getValue() {
        return value;
    }
    
    public int getHeaderIdentifier() {
        return headerIdentifier;
    }
    
    public static VersionType fromProtocolVersion(int headerIdentifier) {
        for (VersionType versionType : values()) {
            if (versionType.getHeaderIdentifier() == headerIdentifier) {
                return versionType;
            }
        }
        throw new IllegalArgumentException("未知头部标识符: " + headerIdentifier);
    }
}
